package com.itheima.ArrayList;

import com.itheima.Domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class DmeoArrayList02 {
    public static void main(String[] args) {
        //ArrayList<>中像放入什么类型就放什么类型,
        // Student类只要在下面创建一个Student类的对象用于接收就可以了.
        ArrayList<Student> li = new ArrayList<>();
        Student stu1 = getStudent(1);
        Student stu2 = getStudent(2);
        Student stu3 = getStudent(3);
        li.add(stu1);
        li.add(stu2);
        li.add(stu3);
        for (int i = 0; i < li.size(); i++) {
            Student stu  = li.get(i);
            System.out.println(stu.getAge()+"..."+stu.getName());
        }

    }
    public static Student getStudent(int count){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第"+count+"个学生姓名:");
        String name = sc.next();
        System.out.println("请输入第"+count+"个学生年龄:");
        String age = sc.next();
        Student stu = new Student(name,age);
        return stu;
    }
    }

